package com.xdu.medical;

import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.concurrent.Task;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import org.kordamp.bootstrapfx.BootstrapFX;
import org.kordamp.ikonli.javafx.FontIcon;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;

public class MainApp extends Application {

    private ImageView originalImageView;
    private ImageView resultImageView;
    private TextFlow textFlow; // 整体的 TextFlow
    private Image selectedImage; // 存储选择的图片
    private File selectedFile; // 存储选择的文件
    private ProgressBar progressBar; // 进度条
    private Task<Void> processingTask; // 模拟处理任务
    private ScrollPane originalScrollPane; // 图片框1的滑动条
    private ScrollPane resultScrollPane; // 图片框2的滑动条
    private StackPane originalImagePane; // 图片框1的容器
    private StackPane resultImagePane; // 图片框2的容器
    private double initialResultScrollPaneWidth; // 记录图片框2的初始宽度
    private double initialResultScrollPaneHeight; // 记录图片框2的初始高度

    @Override
    public void start(Stage primaryStage) {
        // 设置窗口图标
        Image icon = new Image(MainApp.class.getResourceAsStream("SP_Mamba.jpg"));
        primaryStage.getIcons().add(icon);

        // 设置窗口置顶
        primaryStage.setAlwaysOnTop(true);

        // 创建按钮并添加图标
        Button selectButton = new Button("选择图片");
        selectButton.setGraphic(new FontIcon("fas-image"));
        selectButton.getStyleClass().addAll("btn", "btn-primary");

        Button startButton = new Button("开始");
        startButton.setGraphic(new FontIcon("fas-play"));
        startButton.getStyleClass().addAll("btn", "btn-success");

        Button clearButton = new Button("清空");
        clearButton.setGraphic(new FontIcon("fas-trash"));
        clearButton.getStyleClass().addAll("btn", "btn-warning");

        Button stopButton = new Button("中止");
        stopButton.setGraphic(new FontIcon("fas-stop"));
        stopButton.getStyleClass().addAll("btn", "btn-danger");

        Button exportButton = new Button("导出");
        exportButton.setGraphic(new FontIcon("fas-download"));
        exportButton.getStyleClass().addAll("btn", "btn-info");

        // 创建整体的 TextFlow
        textFlow = new TextFlow();
        textFlow.getStyleClass().add("text-flow-custom");
        textFlow.setPrefHeight(60); // 固定高度为 3 行
        textFlow.setMaxHeight(60);

        // 创建两个图片框
        originalImageView = new ImageView();
        originalImageView.setPreserveRatio(true);
        originalImageView.setSmooth(true); // 确保柔和效果
        originalImageView.setStyle("-fx-border-color: #a3c9f1; -fx-border-width: 2; -fx-background-color: #f5f5f5;");

        resultImageView = new ImageView();
        resultImageView.setPreserveRatio(true);
        resultImageView.setSmooth(true); // 确保柔和效果
        resultImageView.setStyle("-fx-border-color: #a3c9f1; -fx-border-width: 2; -fx-background-color: #f5f5f5;");

        // 创建全屏按钮
        Button originalFullScreenButton = new Button();
        originalFullScreenButton.setGraphic(new FontIcon("fas-expand"));
        originalFullScreenButton.getStyleClass().addAll("fullscreen-btn");

        Button resultFullScreenButton = new Button();
        resultFullScreenButton.setGraphic(new FontIcon("fas-expand"));
        resultFullScreenButton.getStyleClass().addAll("fullscreen-btn");

        // 创建图片框容器，包含图片
        originalImagePane = new StackPane();
        originalImagePane.getChildren().add(originalImageView);
        StackPane.setAlignment(originalImageView, Pos.CENTER);

        resultImagePane = new StackPane();
        resultImagePane.getChildren().add(resultImageView);
        StackPane.setAlignment(resultImageView, Pos.CENTER);

        // 创建滑动条包裹图片框
        originalScrollPane = new ScrollPane(originalImagePane);
        originalScrollPane.setFitToWidth(true);
        originalScrollPane.setFitToHeight(true);
        originalScrollPane.setStyle("-fx-background: #f5f5f5; -fx-border-color: #a3c9f1; -fx-border-width: 2;");
        originalScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
        originalScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
        originalScrollPane.setPannable(true);

        resultScrollPane = new ScrollPane();
        resultScrollPane.setFitToWidth(true);
        resultScrollPane.setFitToHeight(true);
        resultScrollPane.setStyle("-fx-background: #f5f5f5; -fx-border-color: #a3c9f1; -fx-border-width: 2;");
        resultScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); // 初始禁用滑动条
        resultScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); // 初始禁用滑动条
        resultScrollPane.setPannable(true);

        // 创建进度条
        progressBar = new ProgressBar(0);
        progressBar.setVisible(false);
        progressBar.getStyleClass().add("progress-bar-custom");

        // 创建外层容器，确保全屏按钮固定在左下角，并向上移动以避免与滚动条重叠
        StackPane originalOuterPane = new StackPane();
        originalOuterPane.getChildren().addAll(originalScrollPane, originalFullScreenButton);
        StackPane.setAlignment(originalFullScreenButton, Pos.BOTTOM_LEFT);
        StackPane.setMargin(originalFullScreenButton, new Insets(0, 0, 20, 10)); // 增加底部边距，向上移动

        StackPane resultOuterPane = new StackPane();
        resultOuterPane.getChildren().addAll(resultScrollPane, resultFullScreenButton);
        StackPane.setAlignment(resultFullScreenButton, Pos.BOTTOM_LEFT);
        StackPane.setMargin(resultFullScreenButton, new Insets(0, 0, 20, 10)); // 增加底部边距，向上移动

        // 将图片框2和进度条叠放在一起
        StackPane resultStack = new StackPane();
        resultStack.getChildren().addAll(resultImagePane, progressBar);
        StackPane.setAlignment(progressBar, Pos.CENTER); // 确保进度条居中
        resultScrollPane.setContent(resultStack);

        // 图片框大小绑定到窗口大小，并记录初始大小
        originalScrollPane.prefWidthProperty().bind(Bindings.min(
                primaryStage.widthProperty().subtract(40),
                primaryStage.heightProperty().subtract(300)
        ));
        originalScrollPane.prefHeightProperty().bind(Bindings.min(
                primaryStage.widthProperty().subtract(40),
                primaryStage.heightProperty().subtract(300)
        ));

        resultScrollPane.prefWidthProperty().bind(Bindings.min(
                primaryStage.widthProperty().subtract(40),
                primaryStage.heightProperty().subtract(300)
        ));
        resultScrollPane.prefHeightProperty().bind(Bindings.min(
                primaryStage.widthProperty().subtract(40),
                primaryStage.heightProperty().subtract(300)
        ));

        // 记录图片框2的初始大小
        initialResultScrollPaneWidth = resultScrollPane.getPrefWidth();
        initialResultScrollPaneHeight = resultScrollPane.getPrefHeight();

        progressBar.prefWidthProperty().bind(resultScrollPane.prefWidthProperty());

        // 动态调整图片大小，滚动条大小不小于图片的 1/2
        originalImageView.imageProperty().addListener((obs, oldImage, newImage) -> {
            if (newImage != null) {
                double width = newImage.getWidth();
                double height = newImage.getHeight();
                double scrollPaneWidth = originalScrollPane.getPrefWidth();
                double scrollPaneHeight = originalScrollPane.getPrefHeight();

                // 滚动条大小不小于图片的 1/2
                double minWidth = width / 2;
                double minHeight = height / 2;
                scrollPaneWidth = Math.max(scrollPaneWidth, minWidth);
                scrollPaneHeight = Math.max(scrollPaneHeight, minHeight);

                // 计算缩放比例，确保图片适应滚动条，但不小于 1/2
                double scale = Math.min(scrollPaneWidth / width, scrollPaneHeight / height);
                if (scale > 1) {
                    scale = 1; // 不放大图片
                }
                originalImageView.setFitWidth(width * scale);
                originalImageView.setFitHeight(height * scale);

                // 确保柔和效果
                originalImageView.setSmooth(true);

                // 确保放大按钮位置固定
                StackPane.setAlignment(originalFullScreenButton, Pos.BOTTOM_LEFT);
                StackPane.setMargin(originalFullScreenButton, new Insets(0, 0, 20, 10));
            } else {
                // 清空图片时重置大小
                originalImageView.setFitWidth(0);
                originalImageView.setFitHeight(0);
            }
        });

        resultImageView.imageProperty().addListener((obs, oldImage, newImage) -> {
            if (newImage != null) {
                double width = newImage.getWidth();
                double height = newImage.getHeight();
                double scrollPaneWidth = resultScrollPane.getPrefWidth();
                double scrollPaneHeight = resultScrollPane.getPrefHeight();

                // 滚动条大小不小于图片的 1/2
                double minWidth = width / 2;
                double minHeight = height / 2;
                scrollPaneWidth = Math.max(scrollPaneWidth, minWidth);
                scrollPaneHeight = Math.max(scrollPaneHeight, minHeight);

                // 计算缩放比例，确保图片适应滚动条，但不小于 1/2
                double scale = Math.min(scrollPaneWidth / width, scrollPaneHeight / height);
                if (scale > 1) {
                    scale = 1; // 不放大图片
                }
                resultImageView.setFitWidth(width * scale);
                resultImageView.setFitHeight(height * scale);

                // 确保柔和效果
                resultImageView.setSmooth(true);

                // 确保放大按钮位置固定
                StackPane.setAlignment(resultFullScreenButton, Pos.BOTTOM_LEFT);
                StackPane.setMargin(resultFullScreenButton, new Insets(0, 0, 20, 10));
            } else {
                // 清空图片时重置大小
                resultImageView.setFitWidth(0);
                resultImageView.setFitHeight(0);
                // 解绑并重置图片框2的大小，然后重新绑定
                resultScrollPane.prefWidthProperty().unbind();
                resultScrollPane.prefHeightProperty().unbind();
                resultScrollPane.setPrefWidth(initialResultScrollPaneWidth);
                resultScrollPane.setPrefHeight(initialResultScrollPaneHeight);
                resultScrollPane.prefWidthProperty().bind(Bindings.min(
                        primaryStage.widthProperty().subtract(40),
                        primaryStage.heightProperty().subtract(300)
                ));
                resultScrollPane.prefHeightProperty().bind(Bindings.min(
                        primaryStage.widthProperty().subtract(40),
                        primaryStage.heightProperty().subtract(300)
                ));
            }
        });

        // 全屏按钮事件
        originalFullScreenButton.setOnAction(event -> {
            if (originalImageView.getImage() != null) {
                showFullScreen(originalImageView.getImage());
            }
        });

        resultFullScreenButton.setOnAction(event -> {
            if (resultImageView.getImage() != null) {
                showFullScreen(resultImageView.getImage());
            }
        });

        // 选择图片按钮事件
        selectButton.setOnAction(event -> {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("选择图片");
            fileChooser.setInitialDirectory(new File("C:\\")); // 默认从 D:\SP-Mamba_img 读取
            fileChooser.getExtensionFilters().addAll(
                    new FileChooser.ExtensionFilter("图片文件", "*.png", "*.jpg", "*.jpeg")
            );
            selectedFile = fileChooser.showOpenDialog(primaryStage);
            if (selectedFile != null) {
                String imagePath = selectedFile.toURI().toString();
                setTextFlowText("选择的图片路径: " + selectedFile.getAbsolutePath());

                // 显示原始图片到图片框1，恢复柔和效果
                selectedImage = new Image(imagePath, 0, 0, true, true, true);
                originalImageView.setImage(selectedImage);
                originalImageView.setSmooth(true); // 确保柔和效果

                // 清空图片框2的状态
                resultImageView.setImage(null);
                progressBar.progressProperty().unbind(); // 解绑进度条
                progressBar.setProgress(0); // 重置进度条
                progressBar.setVisible(false); // 隐藏进度条
                if (processingTask != null) {
                    if (processingTask.isRunning()) {
                        processingTask.cancel(); // 取消正在运行的任务
                    }
                    processingTask = null; // 清空任务引用
                }
                startButton.setDisable(false); // 启用“开始”按钮
                stopButton.setDisable(true); // 禁用“中止”按钮

                // 禁用图片框2的滑动条
                resultScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
                resultScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);

                // 重置图片框2的滚动位置
                resultScrollPane.setHvalue(0);
                resultScrollPane.setVvalue(0);

                // 重置图片框2的视觉状态
                resultImagePane.setStyle(""); // 清空可能的自定义样式
            }
        });

        // 开始按钮事件
        startButton.setOnAction(event -> {
            if (selectedImage == null || selectedFile == null) {
                setTextFlowText("请先选择一张图片！");
                return;
            }

            // 禁用按钮，防止重复点击
            startButton.setDisable(true);
            stopButton.setDisable(false);

            // 显示进度条并确保居中
            progressBar.setVisible(true);
            StackPane.setAlignment(progressBar, Pos.CENTER); // 确保进度条居中
            resultImageView.setImage(null);

            // 重置滚动位置，确保进度条可见
            resultScrollPane.setHvalue(0);
            resultScrollPane.setVvalue(0);

            // 模拟处理任务
            processingTask = new Task<Void>() { // 显式指定类型参数
                @Override
                protected Void call() throws Exception {
                    // 随机延迟 3-5 秒
                    Random random = new Random();
                    int delay = 1500 + random.nextInt(2001); // 2000-4000ms
                    int steps = 100;
                    double stepTime = (double) delay / steps;

                    for (int i = 0; i <= steps; i++) {
                        if (isCancelled()) {
                            break;
                        }
                        updateProgress(i, steps);
                        Thread.sleep((long) stepTime);
                    }
                    return null;
                }
            };

            // 绑定进度条
            progressBar.progressProperty().bind(processingTask.progressProperty());

            // 任务完成后的处理
            processingTask.setOnSucceeded(e -> {
                // 隐藏进度条
                progressBar.setVisible(false);
                startButton.setDisable(false);
                stopButton.setDisable(true);

                // 判断文件名是否以 _img 结尾
                String fileName = selectedFile.getName();
                String originalPath = selectedFile.getAbsolutePath();
                if (!fileName.contains("_img.")) {
                    // 不以 _img 结尾，直接显示原图
                    resultImageView.setImage(selectedImage);
                    resultImageView.setSmooth(true); // 确保柔和效果
                    setTextFlowTextWithHighlight(originalPath, "无病灶");
                } else {
                    // 以 _img 结尾，改后缀为 _amp，尝试多种格式
                    String baseName = fileName.substring(0, fileName.lastIndexOf("_img."));
                    File processedFilePng = new File("D:\\SP-Mamba_amp", baseName + "_amp.png");
                    File processedFileJpg = new File("D:\\SP-Mamba_amp", baseName + "_amp.jpg");
                    File processedFileJpeg = new File("D:\\SP-Mamba_amp", baseName + "_amp.jpeg");

                    File processedFile = null;
                    if (processedFilePng.exists()) {
                        processedFile = processedFilePng;
                    } else if (processedFileJpg.exists()) {
                        processedFile = processedFileJpg;
                    } else if (processedFileJpeg.exists()) {
                        processedFile = processedFileJpeg;
                    }

                    if (processedFile != null) {
                        // 存在改名后的图片，显示该图片
                        Image processedImage = new Image(processedFile.toURI().toString(), 0, 0, true, true, true);
                        resultImageView.setImage(processedImage);
                        resultImageView.setSmooth(true); // 确保柔和效果
                        setTextFlowTextWithHighlight(originalPath, "有病灶");
                    } else {
                        // 不存在改名后的图片，显示原图
                        resultImageView.setImage(selectedImage);
                        resultImageView.setSmooth(true); // 确保柔和效果
                        setTextFlowTextWithHighlight(originalPath, "无病灶");
                    }
                }

                // 恢复图片框2的滑动条策略（仅当有图片时）
                if (resultImageView.getImage() != null) {
                    resultScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
                    resultScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
                } else {
                    resultScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
                    resultScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
                }
            });

            // 任务被取消时的处理
            processingTask.setOnCancelled(e -> {
                progressBar.setVisible(false);
                startButton.setDisable(false);
                stopButton.setDisable(true);
                setTextFlowText("已中止");

                // 清空图片框2的状态
                resultImageView.setImage(null);
                resultScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
                resultScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
            });

            // 启动任务
            new Thread(processingTask).start();
        });

        // 清空按钮事件
        clearButton.setOnAction(event -> {
            // 清空所有状态
            textFlow.getChildren().clear();
            originalImageView.setImage(null);
            resultImageView.setImage(null);
            selectedImage = null;
            selectedFile = null;
            progressBar.progressProperty().unbind(); // 解绑进度条
            progressBar.setProgress(0); // 重置进度条
            progressBar.setVisible(false); // 隐藏进度条
            startButton.setDisable(false);
            stopButton.setDisable(true);
            if (processingTask != null) {
                if (processingTask.isRunning()) {
                    processingTask.cancel();
                }
                processingTask = null; // 清空任务引用
            }

            // 禁用图片框2的滑动条
            resultScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
            resultScrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);

            // 重置图片框2的滚动位置
            resultScrollPane.setHvalue(0);
            resultScrollPane.setVvalue(0);

            // 重置图片框2的视觉状态
            resultImagePane.setStyle(""); // 清空可能的自定义样式
        });

        // 中止按钮事件
        stopButton.setOnAction(event -> {
            if (processingTask != null && processingTask.isRunning()) {
                processingTask.cancel();
            }
        });
        stopButton.setDisable(true); // 初始禁用

        // 导出按钮事件
        exportButton.setOnAction(event -> {
            if (resultImageView.getImage() == null) {
                setTextFlowText("没有输出图片可导出！");
                return;
            }

            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("保存图片");
            fileChooser.setInitialDirectory(new File("C:\\")); // 默认弹出到 C:\
            fileChooser.getExtensionFilters().addAll(
                    new FileChooser.ExtensionFilter("PNG 文件", "*.png"),
                    new FileChooser.ExtensionFilter("JPG 文件", "*.jpg")
            );

            // 设置默认文件名
            fileChooser.setInitialFileName("output");

            File file = fileChooser.showSaveDialog(primaryStage);
            if (file != null) {
                try {
                    // 获取用户选择保存的格式
                    String filePath = file.getAbsolutePath();
                    String saveExtension = getFileExtension(filePath);
                    String format = saveExtension.equalsIgnoreCase("png") ? "png" : "jpg";

                    // 将 JavaFX Image 转换为 BufferedImage
                    Image fxImage = resultImageView.getImage();
                    // 根据保存格式选择 BufferedImage 类型
                    int imageType = format.equalsIgnoreCase("png") ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB;
                    BufferedImage bufferedImage = new BufferedImage(
                            (int) fxImage.getWidth(),
                            (int) fxImage.getHeight(),
                            imageType
                    );
                    for (int x = 0; x < fxImage.getWidth(); x++) {
                        for (int y = 0; y < fxImage.getHeight(); y++) {
                            int argb = fxImage.getPixelReader().getArgb(x, y);
                            bufferedImage.setRGB(x, y, argb);
                        }
                    }

                    // 保存图片
                    boolean success = ImageIO.write(bufferedImage, format, file);
                    if (success) {
                        setTextFlowText("图片已保存到: " + filePath);
                    } else {
                        setTextFlowText("保存失败：无法保存为 " + format.toUpperCase() + " 格式");
                    }
                } catch (IOException e) {
                    setTextFlowText("保存失败：" + e.getMessage());
                } catch (Exception e) {
                    setTextFlowText("保存失败：发生未知错误 - " + e.getMessage());
                }
            }
        });

        // 按钮布局（水平排列）
        HBox buttonBox = new HBox(10);
        buttonBox.setPadding(new Insets(10));
        buttonBox.setAlignment(Pos.CENTER);
        buttonBox.getChildren().addAll(selectButton, startButton, clearButton, stopButton, exportButton);

        // 整体布局
        VBox root = new VBox(15);
        root.setPadding(new Insets(15));
        root.setStyle("-fx-background-color: #f0f4f8;");
        root.getChildren().addAll(buttonBox, textFlow, originalOuterPane, resultOuterPane);

        // 创建场景
        Scene scene = new Scene(root, 600, 800);
        scene.getStylesheets().add(BootstrapFX.bootstrapFXStylesheet());
        scene.getStylesheets().add(getClass().getResource("styles.css").toExternalForm());
        primaryStage.setTitle("SP-Mamba");
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    // 获取文件扩展名
    private String getFileExtension(String fileName) {
        if (fileName == null) return "";
        int dotIndex = fileName.lastIndexOf('.');
        if (dotIndex == -1 || dotIndex == fileName.length() - 1) return "";
        String extension = fileName.substring(dotIndex + 1).toLowerCase();
        return extension.equals("jpeg") ? "jpg" : extension;
    }

    // 设置 TextFlow 普通文本
    private void setTextFlowText(String message) {
        textFlow.getChildren().clear();
        Text text = new Text(message + "\n");
        text.getStyleClass().add("normal-text");
        textFlow.getChildren().add(text);
    }

    // 设置 TextFlow 文本，突出显示“无病灶”或“有病灶”
    private void setTextFlowTextWithHighlight(String path, String highlightText) {
        textFlow.getChildren().clear();
        Text pathText = new Text("图片路径：" + path + "\n");
        pathText.getStyleClass().add("normal-text");
        Text highlight = new Text(highlightText + "\n");
        highlight.getStyleClass().add("highlight-text");
        Text emptyLine = new Text("\n"); // 占位，确保 3 行高度
        textFlow.getChildren().addAll(pathText, highlight, emptyLine);
    }

    // 全屏显示图片
    private void showFullScreen(Image image) {
        Stage fullScreenStage = new Stage();
        fullScreenStage.setTitle("全屏图片");
        fullScreenStage.getIcons().add(new Image(MainApp.class.getResourceAsStream("SP_Mamba.jpg")));

        // 全屏窗口置顶，优先级高于主窗口
        fullScreenStage.setAlwaysOnTop(true);

        ImageView fullScreenImageView = new ImageView(image);
        fullScreenImageView.setPreserveRatio(true);
        fullScreenImageView.setSmooth(true); // 确保柔和效果
        fullScreenImageView.fitWidthProperty().bind(fullScreenStage.widthProperty());
        fullScreenImageView.fitHeightProperty().bind(fullScreenStage.heightProperty());

        StackPane fullScreenPane = new StackPane(fullScreenImageView);
        fullScreenPane.setStyle("-fx-background-color: #000000;");
        StackPane.setAlignment(fullScreenImageView, Pos.CENTER);

        Scene fullScreenScene = new Scene(fullScreenPane);
        fullScreenStage.setScene(fullScreenScene);
        fullScreenStage.setMaximized(true);
        fullScreenStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}